package com.example.demo.StreamTest;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author LHH
 * @date 2025/7/22
 */
public class StreamController {
    public static void main(String[] args) {
        // filter (条件为 true,则返回该数据[符合条件]; false 则屏蔽该数据[不符合条件])
        filterApi();
    }

    private static void filterApi() {

        List<Integer> newList = Arrays.asList(1, 2, 3, 4, 5, 6, 7);
        List<Integer> comparisonList = Arrays.asList(2, 4, 5, 8, 9);
        // info -> comparisonList.contains(info)
        // OR
        // comparisonList::contains
        List<Integer> filterList = newList.stream().filter(comparisonList::contains).collect(Collectors.toList());
        // filterList = [2, 4, 5];
        System.out.println(filterList);

    }
}
